const express = require("express");

const server = express();

// 具名函数格式：
const handler1 = (req, res, next) => {
    let dt = new Date().toLocaleTimeString();
    req.h1 = "h1";
    console.log('h1 = ', dt, req.h1);
    next();
}
server.use(handler1);

// 匿名函数格式：
server.use((req, res, next) => {
    let dt = new Date().toLocaleTimeString();
    req.h2 = "h2";
    console.log('22 = ', dt, req.h1, req.h2);
    next()
}, (req, res) => {
    res.setHeader("content-type", "text/html;charset=utf8");
    let dt = new Date().toLocaleTimeString();
    console.log('over = ', dt);
    res.end("over = " + dt);
});

// server.use((req, res) => {
//     let dt = new Date().toLocaleTimeString();
//     console.log('over = ', dt);
//     res.end("over = " + dt);
// })

server.listen(8001, () => {
    console.log("ok");
})